using System;
using System.Collections.Generic;
using System.Text;
using ECommerce.DAL;
using System.Data.SqlClient;
using System.Data;

namespace Entity
{
    [System.ComponentModel.DataObject]
    public class TblStateTaxExtended : TblStateTax
    {
        public static CustomCollection<TblStateTax> GetNonDeletedStateTaxPaged(string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_NONDELETED_STATE_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblStateTaxCollectionFromReader);
            CustomCollection<TblStateTax> objCollection = ((CustomCollection<TblStateTax>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
        public static int GetNonDeletedStateTaxCount()
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_NONDELETED_STATE_COUNT);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static CustomCollection<TblStateTax> GetActiveStateTaxPaged(string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_ACTIVE_STATE_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblStateTaxCollectionFromReader);
            CustomCollection<TblStateTax> objCollection = ((CustomCollection<TblStateTax>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
        public static int GetActiveStateTaxCount()
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_ACTIVE_STATE_COUNT);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }           

        public static CustomCollection<TblStateTax> GetNonDeletedStateTaxByStateNamePaged(string stateName, string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@stateName", SqlDbType.VarChar, 500, ParameterDirection.Input, stateName);
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_NONDELETED_STATE_BY_STATENAME_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblStateTaxCollectionFromReader);
            CustomCollection<TblStateTax> objCollection = ((CustomCollection<TblStateTax>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;

        }
        public static int GetNonDeletedStateTaxByStateNameCount(string stateName)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@stateName", SqlDbType.VarChar, 500, ParameterDirection.Input, stateName);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_NONDELETED_STATE_BY_STATENAME_COUNT);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static CustomCollection<TblStateTax> GetAllStateTaxByStateNamePaged(string stateName, string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@stateName", SqlDbType.VarChar, 50, ParameterDirection.Input, stateName);
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_ALL_STATE_BY_STATENAME_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblStateTaxCollectionFromReader);
            CustomCollection<TblStateTax> objCollection = ((CustomCollection<TblStateTax>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;

        }
        public static int GetAllStateTaxByStateNameCount(string stateName)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@stateName", SqlDbType.VarChar, 50, ParameterDirection.Input, stateName);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_ALL_STATE_BY_STATENAME_COUNT);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        //public static CustomCollection<TblStateTax> GetAllStateTaxByStateCodePaged(string stateCode, string orderBy, int startRow, int pageSize)
        //{
        //    SqlCommand sqlCmd = new SqlCommand();
        //    AddParameterToSqlCmd(sqlCmd, "@stateCode", SqlDbType.VarChar, 50, ParameterDirection.Input, stateCode);
        //    AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
        //    AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
        //    AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
        //    SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_NONDELETED_STATE_PAGED);
        //    GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblStateTaxCollectionFromReader);
        //    CustomCollection<TblStateTax> objCollection = ((CustomCollection<TblStateTax>)ExecuteReaderCmd(sqlCmd, test));
        //    return objCollection;

        //}
        //public static int GetAllStateTaxByStateCodeCount(string stateCode)
        //{
        //    // Execute SQL Command
        //    SqlCommand sqlCmd = new SqlCommand();
        //    AddParameterToSqlCmd(sqlCmd, "@stateCode", SqlDbType.VarChar, 50, ParameterDirection.Input, stateCode);
        //    AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
        //    SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_ACTIVE_STATE_COUNT);
        //    ExecuteScalarCmd(sqlCmd);
        //    int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
        //    return returnValue;
        //}
        //public static CustomCollection<TblStateTax> GetNonDeletedStateTaxByStateCodePaged(string stateCode, string orderBy, int startRow, int pageSize)
        //{
        //    SqlCommand sqlCmd = new SqlCommand();
        //    AddParameterToSqlCmd(sqlCmd, "@stateCode", SqlDbType.VarChar, 50, ParameterDirection.Input, stateCode);
        //    AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
        //    AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
        //    AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
        //    SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_NONDELETED_STATE_PAGED);
        //    GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblStateTaxCollectionFromReader);
        //    CustomCollection<TblStateTax> objCollection = ((CustomCollection<TblStateTax>)ExecuteReaderCmd(sqlCmd, test));
        //    return objCollection;

        //}
        //public static int GetNonDeletedStateTaxByStateCodeCount(string stateCode)
        //{
        //    // Execute SQL Command
        //    SqlCommand sqlCmd = new SqlCommand();
        //    AddParameterToSqlCmd(sqlCmd, "@stateCode", SqlDbType.VarChar, 50, ParameterDirection.Input, stateCode);
        //    AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
        //    SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_ACTIVE_STATE_COUNT);
        //    ExecuteScalarCmd(sqlCmd);
        //    int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
        //    return returnValue;
        //}

        public static TblStateTax GetStateTaxByStateCode(string stateCode)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@StateCode", SqlDbType.VarChar, 50, ParameterDirection.Input, stateCode);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_STATE_GET_ACTIVE_STATE_BY_CODE);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblStateTaxCollectionFromReader);
            CustomCollection<TblStateTax> objCollection = ((CustomCollection<TblStateTax>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
        }

        private const string SP_TBL_STATE_GET_ALL_STATE_BY_STATENAME_PAGED = "sp_TblState_Get_All_State_By_StateName_Paged";
        private const string SP_TBL_STATE_GET_ALL_STATE_BY_STATENAME_COUNT = "sp_TblState_Get_All_State_By_StateName_Count";

        private const string SP_TBL_STATE_GET_ACTIVE_STATE_PAGED = "sp_TblState_Get_Active_State_Paged";
        private const string SP_TBL_STATE_GET_ACTIVE_STATE_COUNT = "sp_TblState_Get_Active_State_Count";

        private const string SP_TBL_STATE_GET_NONDELETED_STATE_PAGED = "sp_TblState_Get_NonDelete_State_Paged";
        private const string SP_TBL_STATE_GET_NONDELETED_STATE_COUNT = "sp_TblState_Get_NonDelete_State_Count";

        private const string SP_TBL_STATE_GET_NONDELETED_STATE_BY_STATENAME_PAGED = "sp_TblState_Get_NonDelete_State_By_StateName_Paged";
        private const string SP_TBL_STATE_GET_NONDELETED_STATE_BY_STATENAME_COUNT = "sp_TblState_Get_NonDelete_State_By_StateName_Count";
        private const string SP_TBL_STATE_GET_ACTIVE_STATE_BY_CODE = "sp_TblState_Get_Active_State_By_Code";
    }
}

